@extends('layouts.admin')

@section('title', '商品推送')

@section('content')
    <div class="console-title">
        <h2>商品管理->商品推送->分组管理</h2>
    </div>
    <div class="content-div">
        <form method="post" id="listForm" autocomplete="off">
            {{form_verify_field()}}
            <table cellpadding="0" cellspacing="0" width="100%" class="listtable">
                <thead>
                <tr>
                    <th width="40">删?</th>
                    <th width="60">groupid</th>
                    <th width="200">分组名称</th>
                    <th>选项</th>
                </tr>
                </thead>
                <tbody>
                @foreach ($grouplist as $group)
                    <tr>
                        <td><input type="checkbox" class="checkmark" title="" name="delete[]" value="{{$group['groupid']}}"></td>
                        <td>{{$group['groupid']}}</td>
                        <td><input type="text" name="grouplist[{{$group['groupid']}}][grouptitle]" value="{{$group['grouptitle']}}" class="form-control" title=""></td>
                        <td><a href="{{admin_url('itempush/itemlist?groupid='.$group['groupid'])}}">商品管理</a></td>
                    </tr>
                @endforeach
                </tbody>
                <tbody id="newGroup"></tbody>
                <tfoot>
                <tr>
                    <td colspan="5">
                        <label><input type="checkbox" title="" data-action="checkall"> 全选</label>
                        <label><a id="addGroup"><i class="iconfont icon-roundadd"></i><span>添加分组</span></a></label>
                    </td>
                </tr>
                <tr>
                    <td colspan="5" class="btn-group-sm">
                        <label><button type="button" class="btn btn-primary" id="SubmitButton">提交</button></label>
                        <label><button type="button" class="btn btn-default" data-action="refresh">刷新</button></label>
                    </td>
                </tr>
                </tfoot>
            </table>
        </form>
    </div>
    <script type="text/javascript">
        $(function () {
            var k = 0;
            $("#addGroup").on('click', function () {
                $("#newGroup").append('<tr>\n' +
                    '                <td></td>\n' +
                    '                <td></td>\n' +
                    '                <td><input type="text" name="grouplist['+k+'][grouptitle]" class="form-control" title=""></td>\n' +
                    '   <td></td>'+
                    '            </tr>');
                k--;
            });
        });
        $("#SubmitButton").on('click', function () {
            if ($(".checkmark:checked").length > 0) {
                DSXUI.showConfirm('删除确认', '你确认要删除所选项目吗?', function () {
                    $("#listForm").submit();
                });
            } else {
                $("#listForm").submit();
            }
        });
    </script>
@stop
